<template>
  <div class="videos">
    <video ref="videoPlayer" class="video-js" :autoplay="true" controls preload="auto" width="640" height="264" data-setup="{}">
      <source :src="videoSrc" type="video/mp4" />
      <p class="vjs-no-js">
        To view this video please enable JavaScript, and consider upgrading to a web browser that
      </p>
    </video>
  </div>
</template>
<script>
import videojs from 'video.js';
import 'video.js/dist/video-js.css';

export default {
  props: ['videoSrc'],
  data() {
    return {
      player: null
    }
  },
  mounted() {
    this.player = videojs(this.$refs.videoPlayer);
  },
  beforeDestroy() {
    if (this.player) {
      this.player.dispose();
    }
  }
}
</script>
<style lang="scss">
.videos {
  position: relative;
  width: 100%;
  height: calc(100% - 30px);

  .video-js {
    width: 100%;
    height: 100% !important;
  }
}
</style>
